package com.myres.util;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;


public class TimeTool {
	 public static Timestamp String2Timestamp(String format,String dateString){
		   Date date=TimeTool.String2Date(format, dateString);
		   if(date==null) return null;
		   return new Timestamp(date.getTime()); 
	   }
	 public static String time2String(String format,Timestamp time){
		   SimpleDateFormat formatter= new SimpleDateFormat (format);
		   return formatter.format(new Date(time.getTime()));
	   }
	 public static Date String2Date(String format,String dateString){
		   SimpleDateFormat formatter= new SimpleDateFormat (format);
		   try{
		       return formatter.parse(dateString);
		      
		   }catch(Exception e){
			   return null;
		   }
	   }
	 public static String number(float num){
	   if(num==1){
		   return "一";
	   }else if(num==2){
		   return "二";
	   }else if(num==3){
		   return "三";
	   }else if(num==4){
		   return "四";
	   }else if(num==5){
		   return "五";
	   }else if(num==6){
		   return "六";
	   }else if(num==7){
		   return "七";
	   }else if(num==8){
		   return "八";
	   }else if(num==9){
		   return "九";
	   }else if(num==10){
		   return "十";
	   }else if(num==11){
		   return "十一";
	   }else if(num==12){
		   return "十二";
	   }else if(num==13){
		   return "十三";
	   }else if(num==14){
		   return "十四";
	   }else if(num==15){
		   return "十五";
	   }else if(num==16){
		   return "十六";
	   }else if(num==17){
		   return "十七";
	   }else if(num==18){
		   return "十八";
	   }else if(num==19){
		   return "十九";
	   }else if(num==20){
		   return "二十";
	   }
	   return "二十 多";
	 }
}
